<template>
  <div>
    <b-container>
      <b-breadcrumb separator-class="el-icon-arrow-right">
        <!-- <b-breadcrumb-item :to="{ path: '/' }">首页</b-breadcrumb-item> -->
        <b-breadcrumb-item :to="{ path: type == 'news' ? '/news' : 'news?index=1' }">{{type == 'news' ? '公司新闻' : '行业动态'}}</b-breadcrumb-item>
        <b-breadcrumb-item active>详情</b-breadcrumb-item>
      </b-breadcrumb>
      <div class="mb-3" style="text-align: center;">
        <h2 >{{data.title}}</h2>
        <small>发表时间：{{data.created_at}}</small>
      </div>
      
      <div v-html="data.detail.replace(/\/public/g, baseUrl + '/public')"></div>
    </b-container>
  </div>
</template>

<script>
export default {
  name: 'DetailPage',
  async asyncData({route, store, query, redirect, $axios}) {
    const {id = '', type = 'news' } =  query
    const { data } = await $axios.get(`/api/${type}/${id}`)
    return {
      data,
      type,
      baseUrl: process.env.baseUrl
    }
  }
}
</script>

<style>

</style>